//BZOJ 3282
#include <bits/stdc++.h>

using std::swap;

const int maxn=300005;

int ch[maxn][2],fa[maxn],val[maxn],sum[maxn];
bool rev[maxn];

inline void reverse(const int &p){rev[p]^=1;swap(ch[p][0],ch[p][1]);}
inline void pushdown(const int &p){if(rev[p]){if(ch[p][0]) reverse(ch[p][0]);if(ch[p][1]) reverse(ch[p][1]);rev[p]^=1;}}
inline void update(const int &p){sum[p]=sum[ch[p][0]]^sum[ch[p][1]]^val[p];}
inline const bool isroot(const int &p){return ch[fa[p]][0]!=p&&ch[fa[p]][1]!=p;}

void rot(int p){
    int f=fa[p],g=fa[f];
    int x=(ch[f][1]==p),y=(ch[g][1]==f);
    fa[p]=g;if(g&&!isroot(f)) ch[g][y]=p;
    ch[f][x]=ch[p][x^1];if(ch[p][x^1]) fa[ch[p][x^1]]=f;
    ch[p][x^1]=f;if(f) fa[f]=p;
    update(f);
}
void splay(int p){
    static int sta[maxn];
    int t=p,head=0;
    while(!isroot(t)) sta[head++]=t,t=fa[t];
    sta[head++]=t;
    while(head--) pushdown(sta[head]);
    while(!isroot(p)){
        int f=fa[p],g=fa[f];
        int x=(ch[f][1]==p),y=(ch[g][1]==f);
        if(!isroot(f)){
            if(x==y) rot(f);
            else rot(p);
        }
        rot(p);
    }
    update(p);
}
void access(int p){
    for(int son=0;p;son=p,p=fa[p]){
        splay(p);
        ch[p][1]=son;
        update(p);
    }
}
void makeroot(int p){
    access(p);splay(p);reverse(p);
}
void link(int p,int q){
    makeroot(p);fa[p]=q;
}
void cut(int p,int q){
    makeroot(p);access(q);splay(q);
    if(ch[q][0]==p) ch[q][0]=fa[p]=0;
}
inline int find(int p){
    access(p);splay(p);
    while(ch[p][0]) p=ch[p][0];
    return p;
}

template <typename T> inline void read(T &r){
    char c;bool f=0;
    for(c=getchar();c>'9'||c<'0';c=getchar()) if(c=='-') f=1;
    for(r=0;c<='9'&&c>='0';c=getchar()) r=r*10+c-'0';
    if(f) r=-r;
}

int main(){
    int n,m;

    read(n);read(m);
    for(int i=1;i<=n;i++) read(val[i]),sum[i]=val[i];
    while(m--){
        int op,x,y;
        read(op);read(x);read(y);
        if(op==0){makeroot(x);access(y);splay(y);printf("%d\n",sum[y]);}
        else if(op==1){if(find(x)!=find(y)) link(x,y);}
        else if(op==2){if(find(x)==find(y)) cut(x,y);}
        else {splay(x);val[x]=y;update(x);}
    }
    return 0;
}
